package com.nutiteq.kmlzzz;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.List;

import com.nutiteq.components.Place;

public class PlacesList extends List implements CommandListener {

  private static final Command BACK = new Command("Back", Command.BACK, 0);
  
  private Place[] places;

  
  public PlacesList(final Place[] availablePlaces) {
    super("Places", List.MULTIPLE);
    
    places = availablePlaces;
    
    for (int i = 0; i < places.length; i++) {
      append(places[i].getName(), places[i].getIcon());
    }

    addCommand(BACK);
    setCommandListener(this);
  }

  public void commandAction(final Command cmd, final Displayable d) {
    Display.getDisplay(ShowKml.instance).setCurrent(KmlCanvas.instance);
  }
}
